﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTO;

namespace DAO
{
    public class TheLoaiDAO : AbstractDAO
    {
        public List<TheLoaiDTO> GetAll()
        {
            OleDbConnection connection = Open();
            string sql = "SELECT * FROM TheLoai";
            OleDbCommand command = new OleDbCommand(sql, connection);
            OleDbDataReader reader = command.ExecuteReader();
            List<TheLoaiDTO> dsTheLoai = new List<TheLoaiDTO>();
            TheLoaiDTO t;
            while (reader.Read())
            {
                t = new TheLoaiDTO();
                t.MaTheLoai = reader.GetInt32(0);
                t.TenTheLoai = reader.GetString(1);
                t.TinhTrang = reader.GetBoolean(2);
                dsTheLoai.Add(t);
            }
            Close(connection);
            return dsTheLoai;
        }
    }
}
